import * as echarts from "echarts";

export default function (el: HTMLElement) {
  const echartsInstance = echarts.init(el);
  const setOption = (option: echarts.EChartsOption) => {
    echartsInstance.setOption(option);
  };
  const updateSize = () => {
    echartsInstance.resize();
  };
  window.addEventListener("resize", () => {
    echartsInstance.resize();
  });
  return {
    setOption,
    echartsInstance,
    updateSize,
  };
}
